//
//  NewQianbaoJiLuViewController.m
//  wangzhe
//
//  Created by 李 佳伟 on 2018/3/27.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "NewQianbaoJiLuViewController.h"
#import "JTCSM.h"
#import "HuankuanJiluTableViewCell.h"
#import "MyDoubleLabelView.h"

static CGFloat headerimagesize = 20;
@interface NewQianbaoJiLuViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSMutableArray *titlearray;
}
@property (nonatomic,strong) MyDoubleLabelView *headerDoubleView;
@property (nonatomic,strong) UITableView *tableview;
@end

@implementation NewQianbaoJiLuViewController

- (void)gotBack{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = NO;
    [df isRemoveTarbar:YES];
    self.view.backgroundColor = RGBACOLOR(241, 241, 241, 1);
    leftBarButtonItems_rightBarButtonItems *leftbtn = KCUSTOMNAVIGSTION_ALLOC;
    self.navigationItem.leftBarButtonItem = [leftbtn setBarButtonItemsImageName:@"fanhui.png" frame:KLeftBarButtonItemFrame_image target:self SEL:@selector(gotBack)];
    // Do any additional setup after loading the view.
    [self layoutTableView];
}
- (void)layoutTableView{
    
    _tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KCONTROLLERWith, KCONTROLLERHeight)];
    _tableview.delegate = self;
    _tableview.dataSource = self;
    [self.view addSubview:_tableview];
    _tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    _tableview.backgroundColor = RGBACOLOR(241, 241, 241, 1);
}

- (UIView *)layouHeaderViewWithModel:(id)model{
    UIView *backview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KCONTROLLERWith, 50)];
    backview.backgroundColor = RGBACOLOR(241, 241, 241, 1);
    backview.userInteractionEnabled = YES;
    self.headerDoubleView = [[MyDoubleLabelView alloc]initWithFrame:CGRectMake(20, 0, KCONTROLLERWith-100, backview.LC_height) leftTitleFontsize:13 titlecolor:[df colorWithHexString:@"222222" alpha:1] contentFontsize:12 contentcolor:[df colorWithHexString:@"999999" alpha:1]];
    [self.headerDoubleView InsertSpacesetvalueWithModel:model changeLabelY:8];
    [backview addSubview:self.headerDoubleView];
    UIImageView *headerImageV = [[UIImageView alloc]initWithFrame:CGRectMake(KCONTROLLERWith-20-headerimagesize, (backview.LC_height-headerimagesize)/2, headerimagesize, headerimagesize)];
    headerImageV.image = [UIImage imageNamed:@"钱包记录_日历筛选.png"];
    [backview addSubview:headerImageV];
   
    return backview;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *cellid = [NSString stringWithFormat:@"textfield%ld",(long)indexPath.row];
    HuankuanJiluTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid];
    if (cell == nil) {
        cell = [[HuankuanJiluTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid cellType:IsDefulatType];
    }
    [cell setValueWithModel:indexPath];
    cell.stateLabel.text = @"150.00";
    cell.stateLabel.textColor = [df colorWithHexString:@"333333" alpha:1];
    cell.stateLabel.font = [UIFont systemFontOfSize:15];
    return cell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 75;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 50;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    return [self layouHeaderViewWithModel:@{KDoubleLabelTitle:@"2018年3月",KDoubleLabelContent:@"支出¥3000.00   收入¥5000.00"}];
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}


- (void)theRequest{
    [titlearray removeAllObjects];
    titlearray = nil;
    titlearray = [NSMutableArray array];
    
    LoadData *request = [[LoadData alloc]init];
    [request loadDataPostAsynchronousWithURL:KURLPOSTHeadr(@"CreditCard/index") withDict:@{@"token":KTokenString} superView:nil isAddtag:NO Block:^(id result) {
        
        NSString *isreturn = [NSString stringWithFormat:@"%@",[result objectForKey:@"status"]];
        if ([isreturn isEqualToString:@"1"]) {
            
            
            [_tableview reloadData];
        }
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
